package com.modouyu.novel.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.modouyu.common.utils.PageUtils;
import com.modouyu.novel.dao.NovelArticleDao;
import com.modouyu.novel.entity.NovelArticleEntity;
import com.modouyu.novel.service.NovelArticleService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by Administrator on 2018/5/7.
 */
@Service
public class NovelArticleServiceImpl extends ServiceImpl<NovelArticleDao, NovelArticleEntity> implements NovelArticleService {

    @Autowired
    private NovelArticleDao novelArticleDao;

    @Override
    public void updateArticleVisit(Integer id) {
        novelArticleDao.updateArticleVisit(id);
    }

    @Override
    public void updateArticleVote(Integer id) {
        novelArticleDao.updateArticleVote(id);

    }

    @Override
    public PageUtils queryPage(String typevalue, Integer pageno) {

        Page<NovelArticleEntity> page = new Page<NovelArticleEntity>(pageno, 20);
        Wrapper<NovelArticleEntity> ew = new EntityWrapper<NovelArticleEntity>();

        if("quanbu".equalsIgnoreCase(typevalue)){
            ew.eq("fullflag",1);
        }else if("bookstore".equalsIgnoreCase(typevalue)){

        }else {
            ew.eq("typevalue",typevalue);
        }

        page = this.selectPage(page, ew);

        return new PageUtils(page);
    }
}
